package com.meteor.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.meteor.mapper.UserMapper;
import com.meteor.pojo.User;
import com.meteor.service.UserService;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserMapper userMapper;

    @Override
    public User selectUserByUsernameAndPwd(String username, String password) {
        return userMapper.selectUserByUsernameAndPwd(username, password);
    }

    @Override
    public PageInfo<User> selectAll(Integer pageNum, String username) {
        PageHelper.startPage(pageNum,5);
        List<User> users = userMapper.selectAll(username);
        PageInfo<User> userPageInfo = new PageInfo<>(users);
        return userPageInfo;
    }

    @Override
    public int insertUser(User user) {
        return userMapper.insertUser(user);
    }

    @Override
    public User selectUser(String username) {
        return userMapper.selectUser(username);
    }

    @Override
    public int deleteUserById(Integer id) {
        return userMapper.deleteUserById(id);
    }

    @Override
    public int updateUserById(User user) {
        return userMapper.updateUserById(user);
    }

    //-------------------------------------------------前端用户中心--------------------------------------------------------------

    //修改账号密码

    @Override
    public int updateUserByUserName(String newname, String password,String oldname) {
        return userMapper.updateUserByUserName(newname, password,oldname);
    }

    @Override
    public int updateUserMoney(Double money,String username) {
        return userMapper.updateUserMoney(money,username);
    }
}

















